package cn.tedu.qxhouserent.house.controller;

import cn.tedu.qxhouserent.commons.web.JsonResult;
import cn.tedu.qxhouserent.house.pojo.vo.AgentListItemVO;
import cn.tedu.qxhouserent.house.pojo.vo.OrientationListItemVO;

import cn.tedu.qxhouserent.house.pojo.vo.OrientationStandardVO;
import cn.tedu.qxhouserent.house.pojo.vo.SectionStandardVO;
import cn.tedu.qxhouserent.house.service.OrientationService;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.constraints.Range;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/orientation")
@Api(tags = "朝向管理模块")
@Slf4j
public class OrientationController {

    @Autowired
    private OrientationService orientationService;

    @GetMapping("/standard")
    @ApiOperation("根据ID查询朝向")
    @ApiOperationSupport(order = 410)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "朝向ID", required = true, dataType = "long")
    })
    public JsonResult getStandardById(@Range(min = 1, message = "请提交合法的ID值！")
                                      @RequestParam Long id) {
        log.debug("开始处理【根据ID朝向区域】的请求，参数：{}", id);
        OrientationStandardVO orientationStandardVO = orientationService.getStandardById(id);
        log.debug("处理【根据ID查询朝向】完毕");
        return JsonResult.ok(orientationStandardVO);
    }

    @GetMapping("/list")
    @ApiOperation("查询朝向列表")
    @ApiOperationSupport(order = 420)
    public JsonResult list() {
        log.debug("开始处理【查询朝向列表】的请求，参数: 无");

        List<OrientationListItemVO> list = orientationService.list();
        return JsonResult.ok(list);
    }

}
